package ui;

import javax.swing.JPanel;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class RedundancyRow extends JPanel {
    public int index;
    public JCheckBox chckbxIgnore;
    public JLabel lbRedundancy;
    
    public boolean isSelected = false;
    public int indexShowing;
    
    Color colorHover = new Color(192, 192, 192);
    Color colorMinh = new Color(182, 252, 92);
    /**
     * Create the panel.
     */
    public RedundancyRow() {
        addMouseListener(new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent arg0) {
                setBackground(colorHover);
                chckbxIgnore.setBackground(colorHover);
            }
            @Override
            public void mouseExited(MouseEvent e) {
                if (isSelected) {
                    setBackground(colorMinh);
                    chckbxIgnore.setBackground(colorMinh);
                } else {
                    setBackground(null);
                    chckbxIgnore.setBackground(null);
                }
            }
        });
        setBorder(new LineBorder(new Color(0, 0, 0)));
        setLayout(null);
        
        chckbxIgnore = new JCheckBox("");
        chckbxIgnore.setBounds(569, 5, 23, 23);
        add(chckbxIgnore);
        
        lbRedundancy = new JLabel("");
        lbRedundancy.setFont(new Font("Times New Roman", Font.ITALIC, 14));
        lbRedundancy.setBounds(10, 3, 550, 28);
        add(lbRedundancy);

    }
    
    public void setSelected() {
        // chinh mau
        setBackground(colorMinh);
        chckbxIgnore.setBackground(colorMinh);
        // set boolean
        isSelected = true;
    }
    
    public void setNonSelected() {
        // chinh mau
        setBackground(null);
        chckbxIgnore.setBackground(null);
        // set boolean
        isSelected = false;
    }
    
    
}
